t=*map(int,open('input.txt','r').readlines()[1].split()),
c=sum(x<=0 for x in t);n=len(t)
for v in t[:-1]:c+=(v>0)-(v<0);n=min(n,c)
print(n,file=open('output.txt','w'))
#include <map>
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <fstream>
#define ull unsigned long long
#define ll long long
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
ll n;
cin >> n;
vector<ll> mass(n);
vector<ll> dp1(n);
vector<ll> dp2(n);
for (ll i = 0; i < n; ++i) {
cin >> mass[i];
dp1[i]=0, dp2[i]=0;
}
for (ll i = 1; i < n; ++i) {
dp1[i] = dp1[i-1];
if (mass[i-1] >= 0) {
++dp1[i];
}
}
for (ll i = n-2; i >= 0; --i) {
dp2[i] = dp2[i+1];
if (mass[i+1] <= 0) {
++dp2[i];
}
}
ll res = 999999999;
for (ll i = 1; i < n-1; ++i) {
if (mass[i] == 0) {
res = min(res, dp1[i] + dp2[i] + 1);
} else {
res = min(res, dp1[i] + dp2[i]);
}
}
if (mass[n-1] > 0) {
res = min(res, dp1[n-1] + dp2[n-1]);
} if (mass[0] < 0) {
res = min(res, dp1[0] + dp2[0]);
} if (res == 999999999) {
res = mass.size();
}
cout << res;
return 0;
}
/* Sun Mar 12 2023 14:39:01 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 14:39:06 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 14:39:21 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:10:56 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:11:02 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:11:17 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:11:56 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:12:02 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:12:17 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:59:10 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:59:16 GMT+0300 (Moscow Standard Time) */
/* Sun Mar 12 2023 15:59:32 GMT+0300 (Moscow Standard Time) */
/* Mon Mar 13 2023 08:07:34 GMT+0300 (Moscow Standard Time) */
842B - Gleb And Pizza | 1746D - Paths on the Tree |
1651E - Sum of Matchings | 19A - World Football Cup |
630P - Area of a Star | 1030C - Vasya and Golden Ticket |
1529D - Kavi on Pairing Duty | 1743A - Password |
1743B - Permutation Value | 1743C - Save the Magazines |
1743D - Problem with Random Tests | 1070K - Video Posts |
767C - Garland | 1201B - Zero Array |
1584C - Two Arrays | 1131C - Birthday |
1285B - Just Eat It | 1743F - Intersection and Union |
771A - Bear and Friendship Condition | 1208E - Let Them Slide |
656A - Da Vinci Powers | 1025A - Doggo Recoloring |
257A - Sockets | 231C - To Add or Not to Add |
1454E - Number of Simple Paths | 931B - World Cup |
934B - A Prosperous Lot | 999B - Reversing Encryption |
1238D - AB-string | 810B - Summer sell-off |